cmake_minimum_required(VERSION 3.5)

project(PopupMessageBox LANGUAGES CXX)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets REQUIRED)

set(${PROJECT_NAME}_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
set(${PROJECT_NAME}_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)

file(GLOB_RECURSE ${PROJECT_NAME}_HDR_FILES ${${PROJECT_NAME}_INCLUDE_DIR}/*.h ${${PROJECT_NAME}_INCLUDE_DIR}/*.hpp)
file(GLOB_RECURSE ${PROJECT_NAME}_SRC_FILES ${${PROJECT_NAME}_SOURCE_DIR}/*.cpp)

add_library(${PROJECT_NAME} STATIC ${${PROJECT_NAME}_HDR_FILES} ${${PROJECT_NAME}_SRC_FILES})
add_library(PopMsgBox ALIAS ${PROJECT_NAME})

target_link_libraries(${PROJECT_NAME} PUBLIC Qt${QT_VERSION_MAJOR}::Widgets)
target_include_directories(${PROJECT_NAME} PUBLIC ${${PROJECT_NAME}_INCLUDE_DIR})

option(BUILD_EXAMPLE "Build with example" ON)

if(BUILD_EXAMPLE)
	add_subdirectory(example)
	message("Build with example")
endif()
